<template>
	<view>
		<view class="uni-flex uni-row">
			<view v-if="!loginFlag" class="uni-flex-item uni-flex" style="width: 200upx;height: 220upx;align-items: center;">
				<view @click="goToLogin" class="uni-flex-item" style="flex: 12;padding-left: 30rpx;font-size: 40rpx;">
					请登录
				</view>
			</view>
			<view v-if="loginFlag" class="text uni-flex" style="width: 200upx;height: 220upx;-webkit-justify-content: center;
			justify-content: center;-webkit-align-items: center;align-items: center;">
				<image :src="avatarUrl" style="width: 150upx;height: 150upx;"></image>
			</view>
			<view v-if="loginFlag" class="uni-flex uni-column" style="-webkit-flex: 1;flex: 1;-webkit-justify-content: space-between;justify-content: space-between;">
				<view class="text" style="height: 120upx;padding-left: 10upx;padding-top: 10upx;">
					<view class="text" style="-webkit-flex: 1;flex: 1;padding-top: 30upx;font-size: 40rpx;">{{userName}}</view>
				</view>
				<view class="text" style="height: 120upx;padding-left: 10upx;"><view class="text" style="-webkit-flex: 1;flex: 1;color: #888888;">寻医路App</view></view>
			</view>
		</view>
		<uni-list v-if="loginFlag">
			<uni-list-item title="我评论的文章" :show-extra-icon="true" @click="myCommon" :extra-icon="{color: '#000',size: '25',type: 'compose'}"></uni-list-item>
			<!-- <uni-list-item title="我收藏的文章" :show-extra-icon="true" :extra-icon="{color: '#000',size: '25',type: 'star'}"></uni-list-item>
			<uni-list-item title="我评价的医院" :show-extra-icon="true" :extra-icon="{color: '#000',size: '25',type: 'chatboxes'}"></uni-list-item>
			<uni-list-item title="修改密码" :show-extra-icon="true" :extra-icon="{color: '#000',size: '25',type: 'locked'}"></uni-list-item> -->
			<uni-list-item @click="loginOut" title="退出登录" :show-extra-icon="true" :extra-icon="{color: '#000',size: '22',type: 'gear'}"></uni-list-item>
		</uni-list>
	</view>
</template>

<script>
import uniList from '@/components/uni-list/uni-list.vue';
import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
var _self;

export default {
	data() {
		return {
			loginFlag: false,
			userName: '',
			avatarUrl: ''
		};
	},
	
	onLoad: function() {
		_self = this;
		const token = uni.getStorageSync("token");
		if (token != undefined && token != null && token != '') {
			_self.loginFlag = true;
			_self.userName = token.name
			_self.avatarUrl = token.avatar || 'http://thirdqq.qlogo.cn/g?b=oidb&k=gfX9ZPWk6sACVCzibNY5fnw&s=140&t=1558407034'
		} else {
			_self.loginFlag = false;
		}
	},
	methods: {
		goToLogin: function() {
			uni.navigateTo({
				url: '/pages/login/index'
			})
		},
		loginOut: function() {
			uni.removeStorageSync("token");
			uni.removeStorageSync("qq");
			uni.reLaunch({
				url: '../index/index'
			})
		},
		myCommon: function() {
			uni.navigateTo({
				url: './mycommon/mycommon'
			})
		}
	},
	components: { uniList, uniListItem }
};
</script>

<style></style>
